package com.chixing.controller;


import com.chixing.entity.Product;
import com.chixing.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;


import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2022-10-15
 */
@RestController
//@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @Value("{server.port}")
    private String serverPort;

    @GetMapping("/product/{productId}")
    public Product getCustomer(@PathVariable("productId")Integer productId){
        System.out.println("用户正在访问id:"+productId);
        return productService.getById(productId);
    }

    @GetMapping("/selectAll")
    public List<Product> selectAll(){
        return productService.selectAll();
    }
}
